using System;
using System.Collections.Generic;

namespace Gestion.Core.Data.Generic
{
    public interface IGenericDao<T, ID> : IGenericReadOnlyDao<T, ID>
    {
        
        /// <summary>
        /// Refresh'es an already-loaded entity
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        void Refresh(T entity);

        /// <summary>
        /// Marks a transient object as persistent.
        /// </summary>
        /// <param name="entity"></param>
        void Save(T entity);

        /// <summary>
        /// If the object is transient, mark it as persistent.
        /// If it's persistent, update it if it's dirty.
        /// </summary>
        /// <param name="entity"></param>
        void SaveOrUpdate(T entity);

        /// <summary>
        /// Merges an entity with current session's state, 
        /// or saveOrUpdates it if there's no state for it 
        /// in current session.
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        T Merge(T entity);

        /// <summary>
        /// Updates an object
        /// </summary>
        /// <param name="entity"></param>
        void Update(T entity);

        /// <summary>
        /// Marks a persistent object as transient.
        /// </summary>
        /// <param name="entity"></param>
        void Delete(T entity);

        /// <summary>
        /// Deletes an object by its id
        /// </summary>
        /// <param name="id"></param>
        void DeleteById(ID id);
    }
}